package cn.stylefeng.guns.config;

import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;

@Configuration
public class MybatisConfig {



    @Bean
    @Primary
    @ConditionalOnClass(DynamicDataSourceProvider.class)
    public DynamicRoutingDataSource dataSource(DynamicDataSourceProvider dynamicDataSourceProvider) {

        DynamicRoutingDataSource dynamicDataSource = new DynamicRoutingDataSource();
        dynamicDataSource.setPrimary("yaode");
        dynamicDataSource.setStrict(false);
        return dynamicDataSource;
    }
}
